const {defineConfig} = require('@vue/cli-service');

const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')

module.exports = defineConfig({
    lintOnSave: false,
    transpileDependencies: true,
    configureWebpack: {
        plugins: [
            new NodePolyfillPlugin({})
        ]
    },
    pluginOptions: {
        electronBuilder: {
            // 在vue中能引入electron模块
            nodeIntegration: true,
            //preload: "src/preload2.js"
            builderOptions: {
                // 在这里的配置将会和默认配置合并，然后传递给electron-builder
                appId: 'com.huyoubin.voiceoffreedom', // 项目唯一标识
                productName: 'VoiceOfFreedom', // 程序名称
                copyright: 'Copyright © year ${author}', // 可用使用${}引用package.json里面配置项，配置项不存在会报错
                directories: {
                    output: 'dist' // 打包产物的位置
                },
                extraResources: [
                    {from: 'public/resources/static', to: 'static'}
                ],
                // ------- windows 相关配置
                win: {
                    icon: 'icon.ico', // 应用图标
                    target: ['nsis'] // 打包的目标类型,支持很多类型，具体看文档
                },
                nsis: {
                    "oneClick": false,
                    "perMachine": true,
                    "allowToChangeInstallationDirectory": true // 允许修改安装目录
                }
            }
        }
    },
    devServer: {
        proxy: {
            '/kugou': {
                target: 'https://m.kugou.com/',
                changeOrigin: true,
                pathRewrite: {'^/kugou': ''},
                headers: {
                    'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
                }
            },
            '/TKugou': {
                target: 'http://mobilecdnbj.kugou.com/',
                changeOrigin: true,
                pathRewrite: {'^/TKugou': ''},
                headers: {
                    'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
                }
            },
        }
    }
})
